#!user/bin/env python3
# -- coding: utf-8 --
# @Createtime：2022/5/22
# @Updatetime：23:05
# @Author：Test008
# @File：filehandler.py
# @Description：封装处理json文件
import json
import os

jsondir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'datafiles')
print(jsondir)


def parse_json(filepath):
    """
    默认从jsondatas 目录中读取文件。传的文件路经
    useraction/register.json
    :param filepath:
    :return:
    """
    jsonpath = os.path.join(jsondir, filepath)
    print(jsonpath)
    with open(jsonpath, encoding='utf-8') as file:
        testdata = json.load(file)
        return testdata


if __name__ == '__main__':
    data = parse_json(
        r'useraction\register.json')
    print(data)
